﻿using System;
using System.Collections.Generic;
using MugenInjection.Delegates;

namespace MugenInjection.Interface
{
    /// <summary>
    ///     Represents a base interface for scope lifecycle.
    /// </summary>
    public interface IScopeLifecycle : IDisposableObject
    {
        /// <summary>
        ///     Gets or sets the <see cref="IScopeLifecycleContext" />.
        /// </summary>
        IScopeLifecycleContext Context { get; set; }

        /// <summary>
        ///     Gets the actions that should be called before instances are released.
        /// </summary>
        ICollection<Action<object, bool>> ReleaseObjectActions { get; }

        /// <summary>
        ///     Resolves instance for the specified <see cref="IBindingContext" /> from scope.
        /// </summary>
        /// <returns>An instance of the service.</returns>
        object GetObjectFromScope();

        /// <summary>
        ///     Releases all objects in current scope.
        /// </summary>
        /// <param name="isNeedDisposeObject">Indicating that need trying dispose objects.</param>
        void ReleaseObjects(bool isNeedDisposeObject);
    }
}